<?php

namespace Acme\CommonBundle\Twig;

class DateExtension extends \Twig_Extension {
	public function getFilters() {
		return array (
				new \Twig_SimpleFilter ( 'intl_day', array (
						$this,
						'intlDay' 
				) ),
				new \Twig_SimpleFilter ( 'intl_month', array (
						$this,
						'intlMonth' 
				) ) 
		);
	}
	public function intlDay($date, $locale = "de_DE") {
		$fmt = new \IntlDateFormatter ( $locale, \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, 'Europe/Berlin', \IntlDateFormatter::GREGORIAN, 'EEEE' );
		return $fmt->format ( $date );
	}
	public function intlMonth($date, $locale = "de_DE") {
		$fmt = new \IntlDateFormatter ( $locale, \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, 'Europe/Berlin', \IntlDateFormatter::GREGORIAN, 'MMMM' );
		return $fmt->format ( $date );
	}
	public function getName() {
		return 'date_extension';
	}
}